package com.blue.http.controller;

import com.blue.core.auth.CaptchaUtil;
import com.blue.core.dict.HttpMethod;
import com.blue.core.util.RandomUtil;
import com.blue.http.annotation.Http;
import com.blue.http.message.Download;
import com.blue.http.message.HttpRequest;
import org.springframework.stereotype.Controller;

import java.io.IOException;

/**
 * @author zhengjin
 * @since 1.0 2018年03月26日
 */
@Controller
@Http(url = "/verify", method = HttpMethod.GET)
public class VerifyController
{
	public VerifyController()
	{
	}

	public Object index(HttpRequest request)
	{
		return Download.createBuilder().handle(Download.Type.MEMORY, os ->
		{
			try
			{
				String valid = CaptchaUtil.gen(38, 5, RandomUtil.RandomType.NUMBER, os);
				System.out.println(valid);
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}).setFilename("verify.jpg").setDownload(false).build();
	}

}
